package com.service.schedule.msg;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.common.http.HttpResult;
import com.common.model.Global;
import com.dao.sys.MessageDao;
import com.enums.MsgEnum;
import com.model.sys.MessageModel;
import com.service.schedule.ent.SupplyTaskService;
import com.service.sys.WXService;

@Service("msgschduleService")
public class MsgService {
	static final Logger logger = LoggerFactory.getLogger(MsgService.class);

	@Autowired
	MessageDao messageDao;
	@Autowired
	WXService wxService;

	public void sendQYWX() {
		HashMap<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("status", Global.NO + "");
		hashMap.put("msgType", MsgEnum.qywx.getValue());
		List<MessageModel> messageModels = messageDao.selectList(hashMap);
		for (MessageModel messageModel : messageModels) {
			try {
				wxService.sendTxtMessage(messageModel.getMsgReceiveId(), messageModel.getMsgContent());
			} catch (IOException e) {
				logger.error(e.getMessage());
			}
			messageModel.setStatus(Global.YES + "");
			messageDao.update(messageModel);
		}
	}
}
